import { defineStore } from "pinia";

export const userStore = defineStore('user', {
  state: () => ({ 
    addressList: [
      {
        id: '1',
        name: '张三',
        tel: '13000000000',
        address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        isDefault: true
      },
      {
        id: '2',
        name: '李四',
        tel: '13100000000',
        address: '浙江省杭州市拱墅区莫干山路 50 号'
      }
    ],
    disabledList: [
      {
        id: '3',
        name: '王五',
        tel: '13200000000',
        address: '浙江省杭州市滨江区江南大道 15 号'
      }
    ]
  }),
  actions: {  // 方法
    //
    addAddress(content){

      if(content.isDefault){
        this.addressList.map(item => {
          if(item.isDefault){
            item.isDefault = false
          }
        })
      }
      this.addressList.push(content)
    }
  },
  getters: {

  }
});